Skip to content

Update the magnetic energy when enforcing consistency in the interface magnetic field#457

Merged
hyschive merged 15 commits intogamer-project:mainfrom
ChunYen-Chen:sameB
Mar 3, 2026
Merged

Update the magnetic energy when enforcing consistency in the interface magnetic field#457
hyschive merged 15 commits intogamer-project:mainfrom
ChunYen-Chen:sameB

Conversation

@ChunYen-Chen
Copy link
Collaborator

Currently, if MINMOD_MAX_ITER is enabled to reduce the minmod coefficient in each patch, the output of the magnetic field may become inconsistent due to variations in the minmod coefficient across nearby patches.

To address this issue, enabling OPT__SAME_INTERFACE_B enforces consistency of the magnetic field at patch interfaces. However, in the current implementation, the magnetic energy at the interface is not updated.

This PR ensures that magnetic energy is updated when OPT__SAME_INTERFACE_B is enabled.

@hyschive hyschive requested a review from hfhsieh April 13, 2025 13:36
@hyschive hyschive added accuracy Accuracy issues and improvement mhd Magnetohydrodynamics labels Apr 13, 2025
Copy link
Contributor

@hfhsieh hfhsieh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChunYen-Chen @hyschive
Before looking into the details, I would like to ask something:

  • Since it's only during initialization that we do not need to update the magnetic energy in MHD_SameInterfaceB(), I think we can always perform the update, as it should not impact performance.
  • Should we update the wiki documentation to note this behavior under MINMOD_MAX_ITER, or consider automatically enabling OPT__SAME_INTERFACE_B when MINMOD_MAX_ITER > 0 in MHD simulations?

@ChunYen-Chen
Copy link
Collaborator Author

@hfhsieh

Since it's only during initialization that we do not need to update the magnetic energy in MHD_SameInterfaceB(), I think we can always perform the update, as it should not impact performance.

Agreed. I’ll let you know once I’ve updated the code.

Should we update the wiki documentation to note this behavior under MINMOD_MAX_ITER, or consider automatically enabling OPT__SAME_INTERFACE_B when MINMOD_MAX_ITER > 0 in MHD simulations?

I will update the wiki document.
@hyschive Would you like to automatically enabling OPT__SAME_INTERFACE_B when MINMOD_MAX_ITER > 0 in MHD simulations?

@hyschive
Copy link
Contributor

I will update the wiki document. @hyschive Would you like to automatically enabling OPT__SAME_INTERFACE_B when MINMOD_MAX_ITER > 0 in MHD simulations?

Agree. How about declaring OPT__SAME_INTERFACE_B as int instead of bool, setting its value to -1 in all Input__Parameter, and resetting it to either 0 or 1 (if its value is still -1) in Init_ResetParameter.cpp depending on the value of MINMOD_MAX_ITER?

You can also define a corresponding typedef in Typedef.h for OPT__SAME_INTERFACE_B.

Also, remember to raise a warning message in Aux_Check_Parameter.cpp when enabling MINMOD_MAX_ITER for MHD.

@ChunYen-Chen ChunYen-Chen force-pushed the sameB branch 2 times, most recently from ad5338b to aa83e3b Compare April 15, 2025 10:43
@ChunYen-Chen
Copy link
Collaborator Author

@hfhsieh I’ve updated the PR. Please take a look when you have time—thank you in advance!

Copy link
Contributor

@hfhsieh hfhsieh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I have added some comments.

@ChunYen-Chen
Copy link
Collaborator Author

@hfhsieh Thanks for the review. I have addressed the comments.

@hyschive
Copy link
Contributor

@ChunYen-Chen Could you resolve the conflicts caused by the recent wiki updates? Thanks.

Copy link
Contributor

@hyschive hyschive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChunYen-Chen Thanks for the contribution! Please let me know if you agree with the comments I've added. Also, I've filed a potentially related issue (#513).

ChunYen-Chen and others added 6 commits February 26, 2026 06:48
Conflicts:
	doc/wiki/Runtime-Parameters-related/[Runtime-Parameters]-All.md
Co-authored-by: Hsi-Yu Schive <hyschive@gmail.com>
@hyschive
Copy link
Contributor

hyschive commented Mar 1, 2026

@ChunYen-Chen Is it ready for another review?

@ChunYen-Chen
Copy link
Collaborator Author

@hyschive There is one last comment that needs to be resolved. I will let you know once I have finished.

@ChunYen-Chen ChunYen-Chen requested a review from hyschive March 2, 2026 22:24
@ChunYen-Chen
Copy link
Collaborator Author

@hyschive Thanks for the review. The PR has been updated and is ready for the next round of review.

@hyschive hyschive merged commit 0878a15 into gamer-project:main Mar 3, 2026
@ChunYen-Chen ChunYen-Chen deleted the sameB branch March 3, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accuracy Accuracy issues and improvement mhd Magnetohydrodynamics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants